<%@page import="orm.Items"%>
<%@page import="hibernatelogic.HibItems"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Collection"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%
	HttpSession sess = request.getSession();
	
	if (sess.isNew()) {
		response.sendRedirect("/my-pet-project-0/Login.jsp");
	} else {
%>
<%
	if (((String) sess.getAttribute("UserRole")).equals("1")) {
%>
<%
	HibItems hibItems = new HibItems();
			Collection col = null;
			Iterator it = null;
			col = hibItems.getAllItems();
			ArrayList convList = (ArrayList) col;
			it = convList.iterator();
			Items tmpItem = new Items();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Make transactions</title>
</head>
<body>
	<a href="/my-pet-project-0/Login.jsp">Logout</a>
	<a href="/my-pet-project-0/UserStartPage.jsp">Back</a>
	<br>
	<br>
	<center>Fill the form to complete the transaction</center>
	<br>
	<center>
		
		<form action="make-transaction-servlet" method="post"
			name="maketransactionform">
			ITEM: <br> <select name="ntransaction">
				<%
					while (it.hasNext()) {
								tmpItem = (Items) it.next();
				%>
				<option value=<%=tmpItem.getItem_id()%>><%=tmpItem.getItem_name()%>
					<%
						}
					%>
				
			</select> <br> <br> QUANTITY: <br> <select name="nquantity">
				<%
					for (int i = 1; i <= 10; i++) {
				%>
				<option value=<%=i%>><%=i%>
					<%
						}
					%>
				
			</select> <br> <br> <input type="submit" value="Make transaction" onclick="Added()">
		</form>
		
	</center>
	
	<script language="javascript" type="text/javascript">
		function Added(){
			alert("Item added");
		}
	</script>
	
</body>
</html>
<%
	} else {
%>
<%
	response.sendError(response.SC_FORBIDDEN,
					"Not permitted to enter as USER");
%>
<%
	}
	}
%>